package com.liik.game.mvc.simple;

import android.graphics.Canvas;

import com.liik.game.mvc.GameModel;
import com.liik.game.mvc.GameRenderer;
import com.liik.game.mvc.object.Display;
import com.liik.game.mvc.object.Menu;
import com.liik.game.mvc.object.Menu.Item;
import com.liik.game.mvc.object.Navigation;

public abstract class SimpleGameRenderer implements GameRenderer {

	@Override
	public final void render(GameModel model, Navigation navigation, Display display, Canvas canvas) {
		SimpleGameModel gameModel = (SimpleGameModel) model;
		Menu menu = gameModel.getMenu();

		// clear screen first
		renderBackgroundImage(canvas, display.screensize.x, display.screensize.y);

		// draw menu
		for (int i = 0; i < menu.getNumberOfItems(); ++i) {
			Item item = menu.getItem(i);
			if (item != null && item.visible) {
				renderMenuItem(item, canvas);
			}
		}
	}
	
	protected abstract void renderBackgroundImage(Canvas canvas, float width, float height);
	
	protected abstract void renderMenuItem(Item item, Canvas canvas);
}
